package com.chinasoft.movies.controller;

import com.chinasoft.movies.pojo.PageResult;
import com.chinasoft.movies.pojo.Top50Movies;
import com.chinasoft.movies.service.Top50MoviesService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Log4j2
@CrossOrigin
public class Top50MoviesController {

    @Autowired
    Top50MoviesService top50MoviesService;

    //分页查询所有电影中票房前50的电影的票房和总热度，默认每页12条。
    //返回：title(String), revenue(Long), popularity(double), director(String)
    @GetMapping(value = "/queryTop50Movies", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageResult<Top50Movies> queryTop50MoviesByPage(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size) {
        return top50MoviesService.queryTop50MoviesByPage(page, size);
    }
}
